/*******************************************************************
 * 外语翻译平台(translate) 
 *
 * 成都一亿信息技术公司 版权所有
 * 
 * Copyright (C) 2010 Transer Information Technology Co., Ltd.
 *
 * @Version : 1.0  2011-3-1 下午09:40:32
 *
 * ProjectOfferInfoDaoImpl.java 
 *
 *******************************************************************/
package com.transer.persistance.dao.impl;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.transer.persistance.bean.ProjectOfferInfo;
import com.transer.persistance.dao.IProjectOfferInfoDao;
import com.transer.persistance.exception.TranserDatabaseException;

/**
 * class defination are there
 * 
 * @author Mark
 * 
 * @version 1.0 ywengineer@gmail.com
 * 
 */
public class ProjectOfferInfoDaoImpl extends SqlMapClientDaoSupport implements IProjectOfferInfoDao {
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.transer.persistance.dao.IProjectOfferInfoDao#getOfferInfo(int,
	 * int)
	 */
	@Override
	public ProjectOfferInfo getOfferInfo(int project, int user) throws TranserDatabaseException {
		try {
			ProjectOfferInfo param = new ProjectOfferInfo();
			param.setProjectID(project);
			param.setUser(user);
			return (ProjectOfferInfo) getSqlMapClientTemplate().queryForObject("ProjectOfferInfo.getOfferInfoByProjectAndUser", param);
		} catch (DataAccessException e) {
			throw new TranserDatabaseException("getOfferInfo(int project, int user) error");
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.transer.persistance.dao.IProjectOfferInfoDao#addOfferInfo(com.transer
	 * .persistance.bean.ProjectOfferInfo)
	 */
	@Override
	public int addOfferInfo(ProjectOfferInfo info) throws TranserDatabaseException {
		try {
			return (Integer) getSqlMapClientTemplate().insert("ProjectOfferInfo.addProjectOfferInfo", info);
		} catch (DataAccessException e) {
			throw new TranserDatabaseException("添加竞标信息出错");
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.transer.persistance.dao.IProjectOfferInfoDao#updateOfferInfo(com.
	 * transer.persistance.bean.ProjectOfferInfo)
	 */
	@Override
	public void updateOfferInfo(ProjectOfferInfo info) throws TranserDatabaseException {
		try {
			getSqlMapClientTemplate().update("ProjectOfferInfo.updateProjectOfferInfo", info);
		} catch (DataAccessException e) {
			throw new TranserDatabaseException("更新竞标信息出错");
		}
	}

}
